home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / man.3 / GetCursor.3 < prev    next >
Text File  |  1995-07-21  |  12KB  |  374 lines

  1. '\" Copyright (c) 1990 The Regents of the University of California.
  2. '\" All rights reserved.
  3. '\"
  4. '\" Permission is hereby granted, without written agreement and without
  5. '\" license or royalty fees, to use, copy, modify, and distribute this
  6. '\" documentation for any purpose, provided that the above copyright
  7. '\" notice and the following two paragraphs appear in all copies.
  8. '\"
  9. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  10. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  11. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  12. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13. '\"
  14. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  15. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  16. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  17. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  18. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  19. '\" 
  20. '\" $Header: /user6/ouster/wish/man/RCS/GetCursor.3,v 1.9 93/04/01 09:41:26 ouster Exp $ SPRITE (Berkeley)
  21. '\" 
  22. .\" The definitions below are for supplemental macros used in Tcl/Tk
  23. .\" manual entries.
  24. .\"
  25. .\" .HS name section [date [version]]
  26. .\"    Replacement for .TH in other man pages.  See below for valid
  27. .\"    section names.
  28. .\"
  29. .\" .AP type name in/out [indent]
  30. .\"    Start paragraph describing an argument to a library procedure.
  31. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  32. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  33. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  34. .\"    needed;  use .AS below instead)
  35. .\"
  36. .\" .AS [type [name]]
  37. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  38. .\"    name are examples of largest possible arguments that will be passed
  39. .\"    to .AP later.  If args are omitted, default tab stops are used.
  40. .\"
  41. .\" .BS
  42. .\"    Start box enclosure.  From here until next .BE, everything will be
  43. .\"    enclosed in one large box.
  44. .\"
  45. .\" .BE
  46. .\"    End of box enclosure.
  47. .\"
  48. .\" .VS
  49. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  50. .\"    of man pages.
  51. .\"
  52. .\" .VE
  53. .\"    End of vertical sidebar.
  54. .\"
  55. .\" .DS
  56. .\"    Begin an indented unfilled display.
  57. .\"
  58. .\" .DE
  59. .\"    End of indented unfilled display.
  60. .\"
  61. '\"    # Heading for Tcl/Tk man pages
  62. .de HS
  63. .ds ^3 \\0
  64. .if !"\\$3"" .ds ^3 \\$3
  65. .if '\\$2'cmds'       .TH \\$1 1 \\*(^3 \\$4
  66. .if '\\$2'lib'        .TH \\$1 3 \\*(^3 \\$4
  67. .if '\\$2'tcl'        .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands"
  68. .if '\\$2'tk'         .TH \\$1 n \\*(^3 Tk "Tk Commands"
  69. .if '\\$2'tclc'        .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures"
  70. .if '\\$2'tkc'         .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures"
  71. .if '\\$2'tclcmds'         .TH \\$1 1 \\*(^3 Tk "Tcl Applications"
  72. .if '\\$2'tkcmds'         .TH \\$1 1 \\*(^3 Tk "Tk Applications"
  73. .if t .wh -1.3i ^B
  74. .nr ^l \\n(.l
  75. .ad b
  76. ..
  77. '\"    # Start an argument description
  78. .de AP
  79. .ie !"\\$4"" .TP \\$4
  80. .el \{\
  81. .   ie !"\\$2"" .TP \\n()Cu
  82. .   el          .TP 15
  83. .\}
  84. .ie !"\\$3"" \{\
  85. .ta \\n()Au \\n()Bu
  86. \&\\$1    \\fI\\$2\\fP    (\\$3)
  87. .\".b
  88. .\}
  89. .el \{\
  90. .br
  91. .ie !"\\$2"" \{\
  92. \&\\$1    \\fI\\$2\\fP
  93. .\}
  94. .el \{\
  95. \&\\fI\\$1\\fP
  96. .\}
  97. .\}
  98. ..
  99. '\"    # define tabbing values for .AP
  100. .de AS
  101. .nr )A 10n
  102. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  103. .nr )B \\n()Au+15n
  104. .\"
  105. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  106. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  107. ..
  108. '\"    # BS - start boxed text
  109. '\"    # ^y = starting y location
  110. '\"    # ^b = 1
  111. .de BS
  112. .br
  113. .mk ^y
  114. .nr ^b 1u
  115. .if n .nf
  116. .if n .ti 0
  117. .if n \l'\\n(.lu\(ul'
  118. .if n .fi
  119. ..
  120. '\"    # BE - end boxed text (draw box now)
  121. .de BE
  122. .nf
  123. .ti 0
  124. .mk ^t
  125. .ie n \l'\\n(^lu\(ul'
  126. .el \{\
  127. .\"    Draw four-sided box normally, but don't draw top of
  128. .\"    box if the box started on an earlier page.
  129. .ie !\\n(^b-1 \{\
  130. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  131. .\}
  132. .el \}\
  133. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  134. .\}
  135. .\}
  136. .fi
  137. .br
  138. .nr ^b 0
  139. ..
  140. '\"    # VS - start vertical sidebar
  141. '\"    # ^Y = starting y location
  142. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  143. .de VS
  144. .mk ^Y
  145. .ie n 'mc \s12\(br\s0
  146. .el .nr ^v 1u
  147. ..
  148. '\"    # VE - end of vertical sidebar
  149. .de VE
  150. .ie n 'mc
  151. .el \{\
  152. .ev 2
  153. .nf
  154. .ti 0
  155. .mk ^t
  156. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  157. .sp -1
  158. .fi
  159. .ev
  160. .\}
  161. .nr ^v 0
  162. ..
  163. '\"    # Special macro to handle page bottom:  finish off current
  164. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  165. '\"    # page bottom macro.
  166. .de ^B
  167. .ev 2
  168. 'ti 0
  169. 'nf
  170. .mk ^t
  171. .if \\n(^b \{\
  172. .\"    Draw three-sided box if this is the box's first page,
  173. .\"    draw two sides but no top otherwise.
  174. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  175. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  176. .\}
  177. .if \\n(^v \{\
  178. .nr ^x \\n(^tu+1v-\\n(^Yu
  179. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  180. .\}
  181. .bp
  182. 'fi
  183. .ev
  184. .if \\n(^b \{\
  185. .mk ^y
  186. .nr ^b 2
  187. .\}
  188. .if \\n(^v \{\
  189. .mk ^Y
  190. .\}
  191. ..
  192. '\"    # DS - begin display
  193. .de DS
  194. .RS
  195. .nf
  196. .sp
  197. ..
  198. '\"    # DE - end display
  199. .de DE
  200. .fi
  201. .RE
  202. .sp .5
  203. ..
  204. .HS Tk_GetCursor tkc
  205. .BS
  206. .SH NAME
  207. Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor \- maintain database of cursors
  208. .SH SYNOPSIS
  209. .nf
  210. \fB#include <tk.h>\fR
  211. .sp
  212. Cursor
  213. \fBTk_GetCursor(\fIinterp, tkwin, nameId\fB)\fR
  214. .sp
  215. Cursor
  216. \fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR
  217. .sp
  218. char *
  219. .VS
  220. \fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR
  221. .sp
  222. \fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR
  223. .VE
  224. .SH ARGUMENTS
  225. .AS "unsigned long" *pixelPtr
  226. .AP Tcl_Interp *interp in
  227. Interpreter to use for error reporting.
  228. .AP Tk_Window tkwin in
  229. Token for window in which the cursor will be used.
  230. .AP Tk_Uid nameId in
  231. Description of cursor;  see below for possible values.
  232. .AP char *source in
  233. Data for cursor bitmap, in standard bitmap format.
  234. .AP char *mask in
  235. Data for mask bitmap, in standard bitmap format.
  236. .AP "unsigned int" width in
  237. Width of \fIsource\fR and \fImask\fR.
  238. .AP "unsigned int" height in
  239. Height of \fIsource\fR and \fImask\fR.
  240. .AP "unsigned int" xHot in
  241. X-location of cursor hot-spot.
  242. .AP "unsigned int" yHot in
  243. Y-location of cursor hot-spot.
  244. .AP Tk_Uid fg in
  245. Textual description of foreground color for cursor.
  246. .AP Tk_Uid bg in
  247. Textual description of background color for cursor.
  248. .AP Display *display in
  249. Display for which \fIcursor\fR was allocated.
  250. .VS
  251. .VE
  252. .AP Cursor cursor in
  253. X identifier for cursor.  If passed to\fBTk_FreeCursor\fR, must
  254. have been returned by some previous call to \fBTk_GetCursor\fR or
  255. \fBTk_GetCursorFromData\fR.
  256. .BE
  257.  
  258. .SH DESCRIPTION
  259. .PP
  260. These procedures manage a collection of cursors
  261. being used by an application.  The procedures allow cursors to be
  262. re-used efficiently, thereby avoiding server overhead, and also
  263. allow cursors to be named with character strings (actually Tk_Uids).
  264. .PP
  265. \fBTk_GetCursor\fR takes as argument a Tk_Uid describing a cursor,
  266. and returns the X identifier for a cursor corresponding to the
  267. description.  It re-uses an existing cursor if possible and
  268. creates a new one otherwise.  \fINameId\fR must be a standard Tcl
  269. list with one of the following forms:
  270. .TP
  271. \fIname\fR\ \ [\fIfgColor\fR\ \ [\fIbgColor\fR]]
  272. \fIName\fR is the name of a cursor in the standard X cursor font,
  273. i.e., any of the names defined in \fBcursorfont.h\fR, without
  274. the \fBXC_\fR.  Some example values are \fBX_cursor\fR, \fBhand2\fR,
  275. or \fBleft_ptr\fR.  Appendix B of ``The X Window System''
  276. by Scheifler & Gettys has illustrations showing what each of these
  277. cursors looks like.  If \fIfgColor\fR and \fIbgColor\fR are both
  278. specified, they give the foreground and background colors to use
  279. for the cursor (any of the forms acceptable to \fBTk_GetColor\fR
  280. may be used).  If only \fIfgColor\fR is specified, then there
  281. will be no background color:  the background will be transparent.
  282. If no colors are specified, then the cursor
  283. will use black for its foreground color and white for its background
  284. color.
  285. .TP
  286. \fB@\fIsourceName\ \ maskName\ \ fgColor\ \ bgColor\fR
  287. .br
  288. In this form, \fIsourceName\fR and \fImaskName\fR are the names of
  289. files describing bitmaps for the cursor's source bits and mask.
  290. Each file must be in standard X11 or X10 bitmap format.
  291. \fIFgColor\fR and \fIbgColor\fR 
  292. indicate the colors to use for the
  293. cursor, in any of the forms acceptable to \fBTk_GetColor\fR.
  294. .TP
  295. \fB@\fIsourceName\ \ fgColor\fR
  296. .br
  297. This form is similar to the one above, except that the source is
  298. used as mask also.  This means that the cursor's background is transparent.
  299. .PP
  300. \fBTk_GetCursorFromData\fR allows cursors to be created from
  301. in-memory descriptions of their source and mask bitmaps.  \fISource\fR
  302. points to standard bitmap data for the cursor's source bits, and
  303. \fImask\fR points to standard bitmap data describing
  304. which pixels of \fIsource\fR are to be drawn and which are to be
  305. considered transparent.  \fIWidth\fR and \fIheight\fR give the
  306. dimensions of the cursor, \fIxHot\fR and \fIyHot\fR indicate the
  307. location of the cursor's hot-spot (the point that is reported when
  308. an event occurs), and \fIfg\fR and \fIbg\fR describe the cursor's
  309. foreground and background colors textually (any of the forms
  310. suitable for \fBTk_GetColor\fR may be used).  Typically, the
  311. arguments to \fBTk_GetCursorFromData\fR are created by including
  312. a cursor file directly into the source code for a program, as in
  313. the following example:
  314. .nf
  315. .RS
  316. \fCCursor cursor;
  317. #include "source.cursor"
  318. #include "mask.cursor"
  319. cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
  320.     mask_bits, source_width, source_height, source_x_hot,
  321.     source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));\fR
  322. .RE
  323. .fi
  324. .PP
  325. Under normal conditions, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
  326. will return an identifier for the requested cursor.  If an error
  327. occurs in creating the cursor, such as when \fInameId\fR refers
  328. to a non-existent file, then \fBNone\fR is returned and an error
  329. message will be stored in \fIinterp->result\fR.
  330. .PP
  331. \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR maintain a
  332. database of all the cursors they have created.  Whenever possible,
  333. a call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR will
  334. return an existing cursor rather than creating a new one.  This
  335. approach can substantially reduce server overhead, so the Tk
  336. procedures should generally be used in preference to Xlib procedures
  337. like \fBXCreateFontCursor\fR or \fBXCreatePixmapCursor\fR, which
  338. create a new cursor on each call.
  339. .PP
  340. The procedure \fBTk_NameOfCursor\fR is roughly the inverse of
  341. \fBTk_GetCursor\fR.  If its \fIcursor\fR argument was created
  342. by \fBTk_GetCursor\fR, then the return value is the \fInameId\fR
  343. argument that was passed to \fBTk_GetCursor\fR to create the
  344. cursor.  If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,
  345. or by any other mechanism, then the return value is a hexadecimal string
  346. giving the X identifier for the cursor.
  347. Note:  the string returned by \fBTk_NameOfCursor\fR is
  348. only guaranteed to persist until the next call to \fBTk_NameOfCursor\fR.
  349. .PP
  350. When a cursor returned by \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR
  351. is no longer needed, \fBTk_FreeCursor\fR should be called to release it.
  352. There should be exactly one call to \fBTk_FreeCursor\fR for
  353. each call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR.
  354. When a cursor is no longer in use anywhere (i.e. it has been freed as
  355. many times as it has been gotten) \fBTk_FreeCursor\fR will release
  356. it to the X server and remove it from the database.
  357.  
  358. .SH BUGS
  359. In determining whether an existing cursor can be used to satisfy
  360. a new request, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
  361. consider only the immediate values of their arguments.  For
  362. example, when a file name is passed to \fBTk_GetCursor\fR,
  363. \fBTk_GetCursor\fR will assume it is safe to re-use an existing
  364. cursor created from the same file name:  it will not check to
  365. see whether the file itself has changed, or whether the current
  366. directory has changed, thereby causing the name to refer to
  367. a different file.  Similarly, \fBTk_GetCursorFromData\fR assumes
  368. that if the same \fIsource\fR pointer is used in two different calls,
  369. then the pointers refer to the same data;  it does not check to
  370. see if the actual data values have changed.
  371.  
  372. .SH KEYWORDS
  373. cursor
  374.